home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / disk / dvh.h next >
Encoding:
C/C++ Source or Header  |  2008-10-04  |  7.6 KB  |  178 lines

  1. /*
  2.  * Copyright (c) 2000-2001, 2005 Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This program is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU General Public License as
  7.  * published by the Free Software Foundation.
  8.  *
  9.  * This program is distributed in the hope that it would be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write the Free Software Foundation,
  16.  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  17.  */
  18. #ifndef __DVH_H__
  19. #define __DVH_H__
  20.  
  21. /*
  22.  * Format for volume header information
  23.  *
  24.  * The volume header is a block located at the beginning of all disk
  25.  * media (sector 0).  It contains information pertaining to physical
  26.  * device parameters and logical partition information.
  27.  *
  28.  * The volume header is manipulated by disk formatters/verifiers,
  29.  * partition builders (e.g. fx, dvhtool, and mkfs), and disk drivers.
  30.  *
  31.  * Previous versions of IRIX wrote a copy of the volume header is
  32.  * located at sector 0 of each track of cylinder 0.  These copies were
  33.  * never used, and reduced the capacity of the volume header to hold large
  34.  * files, so this practice was discontinued.
  35.  * The volume header is constrained to be less than or equal to 512
  36.  * bytes long.  A particular copy is assumed valid if no drive errors
  37.  * are detected, the magic number is correct, and the 32 bit 2's complement
  38.  * of the volume header is correct.  The checksum is calculated by initially
  39.  * zeroing vh_csum, summing the entire structure and then storing the
  40.  * 2's complement of the sum.  Thus a checksum to verify the volume header
  41.  * should be 0.
  42.  *
  43.  * The error summary table, bad sector replacement table, and boot blocks are
  44.  * located by searching the volume directory within the volume header.
  45.  *
  46.  * Tables are sized simply by the integral number of table records that
  47.  * will fit in the space indicated by the directory entry.
  48.  *
  49.  * The amount of space allocated to the volume header, replacement blocks,
  50.  * and other tables is user defined when the device is formatted.
  51.  */
  52.  
  53. /*
  54.  * device parameters are in the volume header to determine mapping
  55.  * from logical block numbers to physical device addresses
  56.  *
  57.  * Linux doesn't care ...
  58.  */
  59. struct device_parameters {
  60.     unsigned char    dp_skew;    /* spiral addressing skew */
  61.     unsigned char    dp_gap1;    /* words of 0 before header */
  62.     unsigned char    dp_gap2;    /* words of 0 between hdr and data */
  63.     unsigned char    dp_spares_cyl;    /* This is for drives (such as SCSI
  64.         that support zone oriented sparing, where the zone is larger
  65.         than one track.  It gets subracteded from the cylinder size
  66.         ( dp_trks0 * dp_sec) when doing partition size calculations */
  67.     unsigned short    dp_cyls;    /* number of usable cylinders (i.e.,
  68.         doesn't include cylinders reserved by the drive for badblocks,
  69.         etc.). For drives with variable geometry, this number may be
  70.         decreased so that:
  71.         dp_cyls * ((dp_heads * dp_trks0) - dp_spares_cyl) <= actualcapacity
  72.         This happens on SCSI drives such as the Wren IV and Toshiba 156
  73.         Also see dp_cylshi below */
  74.     unsigned short    dp_shd0;    /* starting head vol 0 */
  75.     unsigned short    dp_trks0;    /* number of tracks / cylinder vol 0*/
  76.     unsigned char    dp_ctq_depth;    /* Depth of CTQ queue */
  77.     unsigned char    dp_cylshi;    /* high byte of 24 bits of cylinder count */
  78.     unsigned short    dp_unused;    /* not used */
  79.     unsigned short    dp_secs;    /* number of sectors/track */
  80.     unsigned short    dp_secbytes;    /* length of sector in bytes */
  81.     unsigned short    dp_interleave;    /* sector interleave */
  82.     int    dp_flags;        /* controller characteristics */
  83.     int    dp_datarate;        /* bytes/sec for kernel stats */
  84.     int    dp_nretries;        /* max num retries on data error */
  85.     int    dp_mspw;        /* ms per word to xfer, for iostat */
  86.     unsigned short dp_xgap1;    /* Gap 1 for xylogics controllers */
  87.     unsigned short dp_xsync;    /* sync delay for xylogics controllers */
  88.     unsigned short dp_xrdly;    /* read delay for xylogics controllers */
  89.     unsigned short dp_xgap2;    /* gap 2 for xylogics controllers */
  90.     unsigned short dp_xrgate;   /* read gate for xylogics controllers */
  91.     unsigned short dp_xwcont;   /* write continuation for xylogics */
  92. };
  93.  
  94. /*
  95.  * Device characterization flags
  96.  * (dp_flags)
  97.  */
  98. #define    DP_SECTSLIP    0x00000001    /* sector slip to spare sector */
  99. #define    DP_SECTFWD    0x00000002    /* forward to replacement sector */
  100. #define    DP_TRKFWD    0x00000004    /* forward to replacement track */
  101. #define    DP_MULTIVOL    0x00000008    /* multiple volumes per spindle */
  102. #define    DP_IGNOREERRORS    0x00000010    /* transfer data regardless of errors */
  103. #define DP_RESEEK    0x00000020    /* recalibrate as last resort */
  104. #define    DP_CTQ_EN    0x00000040    /* enable command tag queueing */
  105.  
  106. /*
  107.  * Boot blocks, bad sector tables, and the error summary table, are located
  108.  * via the volume_directory.
  109.  */
  110. #define VDNAMESIZE    8
  111.  
  112. struct volume_directory {
  113.     char    vd_name[VDNAMESIZE];    /* name */
  114.     int    vd_lbn;            /* logical block number */
  115.     int    vd_nbytes;        /* file length in bytes */
  116. };
  117.  
  118. /*
  119.  * partition table describes logical device partitions
  120.  * (device drivers examine this to determine mapping from logical units
  121.  * to cylinder groups, device formatters/verifiers examine this to determine
  122.  * location of replacement tracks/sectors, etc)
  123.  *
  124.  * NOTE: pt_firstlbn SHOULD BE CYLINDER ALIGNED
  125.  */
  126. struct partition_table {        /* one per logical partition */
  127.     int    pt_nblks;        /* # of logical blks in partition */
  128.     int    pt_firstlbn;        /* first lbn of partition */
  129.     int    pt_type;        /* use of partition */
  130. };
  131.  
  132. #define    PTYPE_VOLHDR    0        /* partition is volume header */
  133. #define    PTYPE_TRKREPL    1        /* partition is used for repl trks */
  134. #define    PTYPE_SECREPL    2        /* partition is used for repl secs */
  135. #define    PTYPE_RAW    3        /* partition is used for data */
  136. #define    PTYPE_BSD42    4        /* partition is 4.2BSD file system */
  137. #define    PTYPE_BSD    4        /* partition is 4.2BSD file system */
  138. #define    PTYPE_SYSV    5        /* partition is SysV file system */
  139. #define    PTYPE_VOLUME    6        /* partition is entire volume */
  140. #define    PTYPE_EFS    7        /* partition is sgi EFS */
  141. #define    PTYPE_LVOL    8        /* partition is part of a logical vol */
  142. #define    PTYPE_RLVOL    9        /* part of a "raw" logical vol */
  143. #define    PTYPE_XFS    10        /* partition is sgi XFS */
  144. #define    PTYPE_XFSLOG    11        /* partition is sgi XFS log */
  145. #define    PTYPE_XLV    12        /* partition is part of an XLV vol */
  146. #define    PTYPE_XVM    13        /* partition is sgi XVM */
  147. #define NPTYPES        16
  148.  
  149. #define    VHMAGIC        0xbe5a941    /* randomly chosen value */
  150. #define    NPARTAB        16        /* 16 unix partitions */
  151. #define    NVDIR        15        /* max of 15 directory entries */
  152. #define BFNAMESIZE    16        /* max 16 chars in boot file name */
  153.  
  154. /* Partition types for ARCS */
  155. #define NOT_USED        0       /* Not used                */
  156. #define FAT_SHORT       1       /* FAT filesystem, 12-bit FAT entries    */
  157. #define FAT_LONG        4       /* FAT filesystem, 16-bit FAT entries    */
  158. #define EXTENDED        5       /* extended partition            */
  159. #define HUGE            6       /* huge partition- MS/DOS 4.0 and later */
  160.  
  161. /* Active flags for ARCS */
  162. #define BOOTABLE        0x00;
  163. #define NOT_BOOTABLE    0x80;
  164.  
  165. struct volume_header {
  166.     int vh_magic;                /* identifies volume header */
  167.     short vh_rootpt;            /* root partition number */
  168.     short vh_swappt;            /* swap partition number */
  169.     char vh_bootfile[BFNAMESIZE];        /* name of file to boot */
  170.     struct device_parameters vh_dp;        /* device parameters */
  171.     struct volume_directory vh_vd[NVDIR];    /* other vol hdr contents */
  172.     struct partition_table vh_pt[NPARTAB];    /* device partition layout */
  173.     int vh_csum;                /* volume header checksum */
  174.     int vh_fill;    /* fill out to 512 bytes */
  175. };
  176.  
  177. #endif    /* __DVH_H__ */
  178.